﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Demo.Mmose.Core.Util;

namespace Demo.Mmose.Core.Common.Atom
{
    public class AtomicSbyte : IAtomOperator<sbyte>, IComparable, IComparable<AtomicSbyte>
    {
        #region zh-CHS 构造和初始化和清理 | en Constructors and Initializers and Dispose
        /// <summary>
        /// 
        /// </summary>
        private AtomicSbyte()
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="atomicSbyte"></param>
        private AtomicSbyte( sbyte atomicSbyte )
        {
            m_AtomicSbyte = atomicSbyte;
        }
        #endregion

        #region zh-CHS 属性 | en Properties
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private int m_AtomicSbyte = 0;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public sbyte Value
        {
            get { return (sbyte)m_AtomicSbyte; }
        }
        #endregion

        #region zh-CHS 接口实现 | en Interface Implementation
        /// <summary>
        /// 以原子方式将给定值与当前值相加。
        /// </summary>
        /// <param name="addValue"></param>
        /// <returns></returns>
        public void Add( sbyte addValue )
        {
            Interlocked.Add( ref m_AtomicSbyte, addValue );
        }

        /// <summary>
        /// 以原子方式将给定值与当前值相减。
        /// </summary>
        /// <param name="subtractValue"></param>
        /// <returns></returns>
        public void Subtract( sbyte subtractValue )
        {
            Interlocked.Add( ref m_AtomicSbyte, - subtractValue );
        }

        /// <summary>
        /// 以原子方式将给定值与当前值相乘。
        /// </summary>
        /// <param name="multiplyValue"></param>
        /// <returns></returns>
        public void Multiply( sbyte multiplyValue )
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = (sbyte)m_AtomicSbyte * multiplyValue;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将给定值与当前值相除。
        /// </summary>
        /// <param name="divideValue"></param>
        /// <returns></returns>
        public void Divide( sbyte divideValue )
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = (sbyte)m_AtomicSbyte / divideValue;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }

        /// <summary>
        /// 以原子方式设置为给定值。
        /// </summary>
        /// <param name="assignmentValue"></param>
        /// <returns></returns>
        public void Assignment( sbyte assignmentValue )
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = assignmentValue;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }

        /// <summary>
        /// 如果当前值 == 预期值，则以原子方式将该值设置为给定的更新值。
        /// </summary>
        /// <param name="setValue"></param>
        /// <param name="compareValue"></param>
        /// <returns></returns>
        public bool CompareExchange( sbyte setValue, sbyte compareValue )
        {
            return Interlocked.CompareExchange( ref m_AtomicSbyte, setValue, compareValue ) == compareValue;
        }

        /// <summary>
        /// 以原子方式将当前值减 1 ( -- )
        /// </summary>
        /// <returns></returns>
        public void Decrement()
        {
            Interlocked.Decrement( ref m_AtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将当前值加 1 ( ++ )
        /// </summary>
        /// <returns></returns>
        public void Increment()
        {
            Interlocked.Increment( ref m_AtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将当前值左移 ( << )
        /// </summary>
        /// <returns></returns>
        public void LeftShift( int leftShift )
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = (sbyte)m_AtomicSbyte << leftShift;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将当前值右移 ( >> )
        /// </summary>
        /// <returns></returns>
        public void RightShift( int rightShift )
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = (sbyte)m_AtomicSbyte >> rightShift;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将当前值求正(一元操作) ( + )
        /// </summary>
        /// <param name="addValue"></param>
        /// <returns></returns>
        public void Plus()
        {
            // 不用执行，本来就是正值
        }

        /// <summary>
        /// 以原子方式将当前值求负(一元操作) ( - )
        /// </summary>
        /// <param name="addValue"></param>
        /// <returns></returns>
        public void Minus()
        {
            throw new NotSupportedException();
        }

        /// <summary>
        /// 以原子方式将当前值取反(一元操作) ( ! )
        /// </summary>
        /// <param name="addValue"></param>
        /// <returns></returns>
        public void Invert()
        {
            throw new NotSupportedException();
        }

        /// <summary>
        /// 以原子方式将当前值求补 ( ~ )
        /// </summary>
        /// <returns></returns>
        public void OneComplement()
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = ~(sbyte)m_AtomicSbyte;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将当前值按位与 ( &= )
        /// </summary>
        /// <returns></returns>
        public void BitwiseAND( sbyte bitwiseAnd )
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = (sbyte)m_AtomicSbyte & bitwiseAnd;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将当前值按位或 ( |= )
        /// </summary>
        /// <returns></returns>
        public void BitwiseInclusiveOR( sbyte inclusiveOR )
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = (sbyte)m_AtomicSbyte | inclusiveOR;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将当前值按位异或 ( ^= )
        /// </summary>
        /// <returns></returns>
        public void BitwiseExclusiveOR( sbyte exclusiveOR )
        {
            int oldAtomicSbyte;
            int newAtomicSbyte;

            do
            {
                oldAtomicSbyte = (sbyte)m_AtomicSbyte;
                newAtomicSbyte = (sbyte)m_AtomicSbyte ^ exclusiveOR;

            } while ( Interlocked.CompareExchange( ref m_AtomicSbyte, newAtomicSbyte, oldAtomicSbyte ) != oldAtomicSbyte );
        }
        #endregion

        #region zh-CHS 共有委托 | en Public Delegate
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<UpdatingValue<sbyte>> m_EventUpdatingValue;
        /// <summary>
        /// 
        /// </summary>
        private SpinLock m_LockEventUpdating = new SpinLock();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<UpdatingValue<sbyte>> UpdatingValue
        {
            add
            {
                SpinLockEx.ReliableEnter( ref m_LockEventUpdating );
                {
                    m_EventUpdatingValue += value;
                }
                m_LockEventUpdating.Exit();
            }
            remove
            {
                SpinLockEx.ReliableEnter( ref m_LockEventUpdating );
                {
                    m_EventUpdatingValue -= value;
                }
                m_LockEventUpdating.Exit();
            }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<UpdatedValue<sbyte>> m_EventUpdatedValue;
        /// <summary>
        /// 
        /// </summary>
        private SpinLock m_LockEventUpdated = new SpinLock();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<UpdatedValue<sbyte>> UpdatedValue
        {
            add
            {
                SpinLockEx.ReliableEnter( ref m_LockEventUpdated );
                {
                    m_EventUpdatedValue += value;
                }
                m_LockEventUpdated.Exit();
            }
            remove
            {
                SpinLockEx.ReliableEnter( ref m_LockEventUpdated );
                {
                    m_EventUpdatedValue -= value;
                }
                m_LockEventUpdated.Exit();
            }
        }
        #endregion

        #region zh-CHS 方法 | en Method
        /// <summary>
        /// 将当前值左移 ( << )，并返回左移后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator >>( AtomicSbyte atomicSbyteA, int atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte >> atomicSbyteB ) );
        }

        /// <summary>
        /// 将当前值右移 ( >> )，并返回右移后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator <<( AtomicSbyte atomicSbyteA, int atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte << atomicSbyteB ) );
        }

        /// <summary>
        /// 将给定值与当前值相加，并返回相加后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator +( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte + atomicSbyteB ) );
        }

        /// <summary>
        /// 将给定值与当前值相加，并返回相加后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator +( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte + (sbyte)atomicSbyteB.m_AtomicSbyte ) );
        }

        /// <summary>
        /// 将给定值与当前值相减，并返回相减后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator -( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte - atomicSbyteB ) );
        }

        /// <summary>
        /// 将给定值与当前值相减，并返回相减后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator -( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte - (sbyte)atomicSbyteB.m_AtomicSbyte ) );
        }

        /// <summary>
        /// 将给定值与当前值相乘，并返回相乘后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator *( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte * atomicSbyteB ) );
        }

        /// <summary>
        /// 将给定值与当前值相乘，并返回相乘后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator *( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte * (sbyte)atomicSbyteB.m_AtomicSbyte ) );
        }

        /// <summary>
        /// 将当前值与给定值相除，并返回相除后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator /( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte / atomicSbyteB ) );
        }

        /// <summary>
        /// 将当前值与给定值相除，并返回相除后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator /( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte / (sbyte)atomicSbyteB.m_AtomicSbyte ) );
        }

        /// <summary>
        /// 将当前值与给定值相模，并返回相模后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator %( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte % atomicSbyteB ) );
        }

        /// <summary>
        /// 将当前值与给定值相模，并返回相模后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator %( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte % (sbyte)atomicSbyteB.m_AtomicSbyte ) );
        }

        /// <summary>
        /// 将当前值与给定值相与，并返回相与后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator &( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte & atomicSbyteB ) );
        }

        /// <summary>
        /// 将当前值与给定值相与，并返回相与后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator &( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte & (sbyte)atomicSbyteB.m_AtomicSbyte ) );
        }

        /// <summary>
        /// 将当前值与给定值相或，并返回相或后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator |( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte | atomicSbyteB ) );
        }

        /// <summary>
        /// 将当前值与给定值相或，并返回相或后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator |( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte | (sbyte)atomicSbyteB.m_AtomicSbyte ) );
        }

        /// <summary>
        /// 将当前值与给定值相异或，并返回相异或后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator ^( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte ^ atomicSbyteB ) );
        }

        /// <summary>
        /// 将当前值与给定值相异或，并返回相异或后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <param name="atomicSbyteB"></param>
        /// <returns></returns>
        public static AtomicSbyte operator ^( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return new AtomicSbyte( (sbyte)( (sbyte)atomicSbyteA.m_AtomicSbyte ^ (sbyte)atomicSbyteB.m_AtomicSbyte ) );
        }

        /// <summary>
        /// 将当前值求补，并返回求补后的数据
        /// </summary>
        /// <param name="atomicSbyteA"></param>
        /// <returns></returns>
        public static AtomicSbyte operator ~( AtomicSbyte atomicSbyte )
        {
            return new AtomicSbyte( (sbyte)~(sbyte)atomicSbyte.m_AtomicSbyte );
        }

        /// <summary>
        /// 以原子方式将当前值加 1 ( ++ )
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static AtomicSbyte operator ++( AtomicSbyte atomicSbyte )
        {
            atomicSbyte.Increment();

            return atomicSbyte;
        }

        /// <summary>
        /// 以原子方式将当前值减 1 ( -- )
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static AtomicSbyte operator --( AtomicSbyte atomicSbyte )
        {
            atomicSbyte.Decrement();

            return atomicSbyte;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator ==( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte == (sbyte)atomicSbyteB.m_AtomicSbyte;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator ==( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte == atomicSbyteB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator !=( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte != (sbyte)atomicSbyteB.m_AtomicSbyte;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator !=( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte != atomicSbyteB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator <( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte < (sbyte)atomicSbyteB.m_AtomicSbyte;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator <( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte < atomicSbyteB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator >( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte > (sbyte)atomicSbyteB.m_AtomicSbyte;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator >( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte > atomicSbyteB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator <=( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte <= (sbyte)atomicSbyteB.m_AtomicSbyte;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator <=( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte <= atomicSbyteB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator >=( AtomicSbyte atomicSbyteA, AtomicSbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte >= (sbyte)atomicSbyteB.m_AtomicSbyte;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="l"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool operator >=( AtomicSbyte atomicSbyteA, sbyte atomicSbyteB )
        {
            return (sbyte)atomicSbyteA.m_AtomicSbyte >= atomicSbyteB;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="iSerial"></param>
        /// <returns></returns>
        public static explicit operator sbyte( AtomicSbyte atomicSbyte )
        {
            return (sbyte)atomicSbyte.m_AtomicSbyte;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="atomicSbyte"></param>
        /// <returns></returns>
        public static implicit operator AtomicSbyte( sbyte atomicSbyte )
        {
            return new AtomicSbyte( atomicSbyte );
        }
        #endregion

        #region zh-CHS 方法覆盖 | en Method Overrides
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return m_AtomicSbyte.ToString();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return m_AtomicSbyte.GetHashCode();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="xObject"></param>
        /// <returns></returns>
        public override bool Equals( object xObject )
        {
            AtomicSbyte atomicSbyte = xObject as AtomicSbyte;
            if ( atomicSbyte == null )
                return false;

            return (sbyte)atomicSbyte.m_AtomicSbyte == (sbyte)m_AtomicSbyte;
        }
        #endregion

        #region zh-CHS 接口实现 | en Interface Implementation
        /// <summary>
        /// 
        /// </summary>
        /// <param name="otherAtomicInt"></param>
        /// <returns></returns>
        public int CompareTo( AtomicSbyte otherAtomicInt )
        {
            return ( (sbyte)m_AtomicSbyte ).CompareTo( (sbyte)otherAtomicInt.m_AtomicSbyte );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="otherObject"></param>
        /// <returns></returns>
        public int CompareTo( object otherObject )
        {
            AtomicSbyte atomicSbyte = otherObject as AtomicSbyte;
            if ( atomicSbyte == null )
                return 1;
            else
                return CompareTo( atomicSbyte );
        }
        #endregion
    }
}
